package com.example.work4jpa.Service;

import com.example.work4jpa.Dao.CourseDao;
import com.example.work4jpa.Entity.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class CourseService {
    @Autowired
    CourseDao courseDao;

    public List<Course> findAll(){
        return courseDao.findAll();
    }
    public Course save(Course course){
        return courseDao.save(course);
    }
    public Course getByName(String name){
        return courseDao.findByName(name);
    }
    @Transactional
    public void deleteByName(String name) {
        courseDao.deleteByName(name);
    }
    public Page<Course> findAll(Pageable pageable){
        return courseDao.findAll(pageable);
    }

}
